package com.changgou.search.controller;

import com.changgou.entity.Result;
import com.changgou.entity.StatusCode;
import com.changgou.search.service.SearchManageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author: zhengke
 * @date: 2020/12/18
 * @return:
 * @description:
 */

@RestController
public class SearchManageController {
    @Autowired
    private SearchManageService searchManageService;

    @PostMapping("/createIndex")
    public Result createIndex(){
        searchManageService.createIndex();
        return new Result(true,StatusCode.OK,"创建索引库成功");
    }

    @PostMapping("/deleteIndex")  //PostMapping 完全可以替代另外几种
    public Result deleteIndex(){
        searchManageService.deleteIndex();
        return new Result(true,StatusCode.OK,"删除索引库成功");
    }

    @PostMapping("/importAll")
    public Result importAll(){
        searchManageService.importAll();
        return new Result(true,StatusCode.OK,"导入所有数据到索引库成功");
    }
}
